<template>
  <el-container>
    <el-tabs v-model="activeName" style="margin-left: 20px;margin-top: 20px">
      <el-tab-pane label="选择规则类型"  name="first">
        <el-form
          ref="rulePowerForm"
          :model="rulePowerForm"
          class="dataForm"
        >
          <el-form-item
            prop="obtainMode"
            class="mb30 w326 labelTextSize14 errorInfoPosition labelColor666"
          >
            <span style="color:red">*</span>
            <span class="font14 color666">规则类型：</span>
            <el-select
              v-model="rulePowerForm.obtainMode"
              clearable
              @change="selectModel($event)"
              placeholder="请选择规则类型"
              :size="size"
              :disabled="editTypeDis"
            >
              <el-option
                v-for="item in obtainModeTypeList"
                :key="item.obtainMode"
                :label="item.obtainName"
                :value="item.obtainMode"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="ruleName" class="mb120 w326 labelTextSize14 labelColor666">
            <span style="color:red">*</span>
            <span class="font14 color666">规则名称：</span>
            <el-input v-model="rulePowerForm.ruleName" clearable maxlength="20" style="width: 300px" placeholder="请输入规则名称" :size="size"></el-input>
          </el-form-item>
          <div class="t_c">
            <el-button
              :size="size"
              type="primary"
              plain
              @click="returnRuleList"
              class="mr60"
            >返回</el-button>
            <el-button
              :size="size"
              type="primary"
              @click="nextStepRulePower(1)"
              :loading="editLoading"
            >下一步</el-button>
          </div>
        </el-form>
      </el-tab-pane>

      <el-tab-pane label="设置规则" :disabled="true" name="second">
        <el-form
          ref="rulePowerForm"
          class="formItemNoMargin"
          :model="rulePowerForm"
          :size="size"
        >
          <el-row v-show="give">
            <el-row class="mb30">
              <span class="font16 color000">注册赠送</span>
            </el-row>
            <el-form-item
              class="mb120 labelColor666 labelTextSize14 w200"
              prop="giveIntegralNum"
            >
              <span style="color:red">*</span>
              <span class="color666">用户注册发放：</span>
              <el-input
                placeholder="输入数字"
                v-model="rulePowerForm.giveIntegralNum"
                class="newUserRegister"
                @input="rulePowerForm.giveIntegralNum=rulePowerForm.giveIntegralNum.replace(/[^\d.]/g,'')"
                maxlength="5"
                clearable
              ></el-input>&nbsp;&nbsp;积分
            </el-form-item>
          </el-row>
          <el-row v-show="order">
            <el-form-item class="mb30">
              <span class="font16 color000">下单赠送</span>
            </el-form-item>
            <el-form-item class="formItemNoMargin">
              <el-radio-group v-model="rulePowerForm.orderFlag" class="mb30">
                <el-radio label="1" class="form-radio mr60 color333">每消费赠送</el-radio>
                <el-radio label="2" class="form-radio color333">阶梯消费赠送</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item v-show="rulePowerForm.orderFlag==1" class="formItemNoMargin">
              <el-form-item
                class="labelTextColor666 labelTextSize14 mb30"
              >
                <span style="color:red">*</span>
                <span class="color666">每消费：</span>
                <el-input
                  placeholder="请输入"
                  v-model="rulePowerForm.consumeNum"
                  maxlength="5"
                  class="w138"
                  @input="rulePowerForm.consumeNum=rulePowerForm.consumeNum.replace(/[^\d.]/g,'')"
                  clearable
                ></el-input>
                <span class="color666 m_l10 turnInlineBlock mr5">&nbsp;元，赠送&nbsp;</span>
                <el-input
                  placeholder="请输入"
                  v-model="rulePowerForm.giveIntegralNum"
                  maxlength="5"
                  @input="rulePowerForm.giveIntegralNum=rulePowerForm.giveIntegralNum.replace(/[^\d.]/g,'')"
                  class="w138"
                  clearable
                ></el-input>
                <span class="color666 m_l10 turnInlineBlock">积分</span>
              </el-form-item>
              <el-form-item label="每日上限：" class="labelTextColor666 mb120 labelTextSize14">
                <el-input
                  placeholder="请输入"
                  v-model="rulePowerForm.giveIntegralMaxNum"
                  maxlength="5"
                  class="w365"
                  clearable
                  @input="rulePowerForm.giveIntegralMaxNum=rulePowerForm.giveIntegralMaxNum.replace(/[^\d.]/g,'')"
                ></el-input>
              </el-form-item>
            </el-form-item>
            <el-form-item v-show="rulePowerForm.orderFlag==2">
              <div v-for="(item,index) in rulePowerForm.mememberIntegraIncrement" :key="index">
                <el-form-item  class="formItemNoMargin">
                  <el-form-item
                    prop="consumeNum"
                    label-width="15px"
                    class="labelTextSize14 labelTextColor666 mb30 turnInlineBlock form-item-content-noMargin "
                  >
                    <span style="color:red">*</span>
                    <span class="color666">消费：</span>
                    <el-input
                      type="text"
                      v-model="rulePowerForm.mememberIntegraIncrement[index].consumeNum"
                      maxlength="5"
                      placeholder="输入数字"
                      @input="rulePowerForm.mememberIntegraIncrement[index].consumeNum=rulePowerForm.mememberIntegraIncrement[index].consumeNum.replace(/[^\d.]/g,'')"
                      class="w138"
                      clearable
                    ></el-input>
                    <span class="m_l5 turnInlineBlock">元，赠送&nbsp;</span>
                  </el-form-item>
                  <el-form-item
                    prop="giveIntegralNum"
                    class="turnInlineBlock form-item-content-noMargin formItemNoMargin"
                  >
                    <el-input
                      type="text"
                      v-model="rulePowerForm.mememberIntegraIncrement[index].giveIntegralNum"
                      maxlength="5"
                      placeholder="输入数字"
                      @input="rulePowerForm.mememberIntegraIncrement[index].giveIntegralNum=rulePowerForm.mememberIntegraIncrement[index].giveIntegralNum.replace(/[^\d.]/g,'')"
                      class="w138"
                      clearable
                    ></el-input>
                    <span class="m_l5 turnInlineBlock">积分</span>
                  </el-form-item>
                  <el-button
                    :size="size"
                    type="text"
                    @click="addOrderGivenStairArr(index)"
                    v-show="index==0"
                    class="textBtn"
                  >添加</el-button>
                  <el-button
                    :size="size"
                    type="text"
                    @click="deelteOrderGivenStairArr(index)"
                    v-show="index != 0"
                    class="textRed noMarginL textBtn"
                  >删除</el-button>
                </el-form-item>
              </div>
              <el-form-item label="每日上限：" class="labelTextSize14 labelTextColor666 mb120">
                <el-input
                  placeholder="请输入"
                  v-model="rulePowerForm.giveIntegralMaxNum"
                  maxlength="5"
                  clearable
                  class="w350"
                  @input="rulePowerForm.giveIntegralMaxNum=rulePowerForm.giveIntegralMaxNum.replace(/[^\d.]/g,'')"
                  maxl
                ></el-input>
              </el-form-item>
            </el-form-item>
          </el-row>
          <el-row v-show="recharge">
            <el-form-item class="mb30">
              <span class="font16 color000">充值赠送</span>
            </el-form-item>
            <el-form-item class="formItemNoMargin">
              <el-radio-group v-model="rulePowerForm.consumeFlag" class="mb30">
                <el-radio label="1" class="form-radio mr60 color333">每充值赠送</el-radio>
                <el-radio label="2" class="form-radio color333">阶梯充值赠送</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item v-show="rulePowerForm.consumeFlag==1" class="formItemNoMargin">
              <el-form-item
                class="labelTextColor666 labelTextSize14 mb30"
              >
                <span style="color:red">*</span>
                <span class="color666">每充值：</span>
                <el-input
                  placeholder="请输入"
                  clearable
                  v-model="rulePowerForm.consumeNum"
                  @input="rulePowerForm.consumeNum=rulePowerForm.consumeNum.replace(/[^\d.]/g,'')"
                  maxlength="5"
                  class="w138"
                ></el-input>
                <span class="color666 m_l5 turnInlineBlock mr5">元，赠送</span>
                <el-input
                  placeholder="请输入"
                  clearable
                  v-model="rulePowerForm.giveIntegralNum"
                  @input="rulePowerForm.giveIntegralNum=rulePowerForm.giveIntegralNum.replace(/[^\d.]/g,'')"
                  maxlength="5"
                  class="w138"
                ></el-input>
                <span class="color666 m_l10 turnInlineBlock">积分</span>
              </el-form-item>
              <el-form-item label="每日上限：" class="labelTextColor666 mb120 labelTextSize14">
                <el-input
                  placeholder="请输入数字"
                  clearable
                  v-model="rulePowerForm.giveIntegralMaxNum"
                  @input="rulePowerForm.giveIntegralMaxNum=rulePowerForm.giveIntegralMaxNum.replace(/[^\d.]/g,'')"
                  maxlength="5"
                  class="w350"
                ></el-input>
              </el-form-item>
            </el-form-item>
            <el-form-item v-show="rulePowerForm.consumeFlag==2">
              <div v-for="(item,index) in rulePowerForm.mememberIntegraIncrement" :key="index">
                <el-form-item  class="formItemNoMargin">
                  <el-form-item
                    prop="consumeNum"
                    class="labelTextSize14 labelTextColor666 mb30 turnInlineBlock form-item-content-noMargin"
                    label-width="15px"
                  >
                    <span style="color:red">*</span>
                    <span class="color666">充值：</span>
                    <el-input
                      type="text"
                      v-model="rulePowerForm.mememberIntegraIncrement[index].consumeNum"
                      maxlength="5"
                      placeholder="输入数字"
                      @input="rulePowerForm.mememberIntegraIncrement[index].consumeNum=rulePowerForm.mememberIntegraIncrement[index].consumeNum.replace(/[^\d.]/g,'')"
                      class="w138"
                      clearable
                    ></el-input>
                    <span class="m_l5 turnInlineBlock">元，赠送&nbsp;</span>
                  </el-form-item>
                  <el-form-item
                    prop="giveIntegralNum"
                    class="turnInlineBlock form-item-content-noMargin formItemNoMargin"
                  >
                    <el-input
                      type="text"
                      v-model.number="rulePowerForm.mememberIntegraIncrement[index].giveIntegralNum"
                      maxlength="5"
                      placeholder="输入数字"
                      @input="rulePowerForm.mememberIntegraIncrement[index].giveIntegralNum=rulePowerForm.mememberIntegraIncrement[index].giveIntegralNum.replace(/[^\d.]/g,'')"
                      class="w138"
                      clearable
                    ></el-input>
                    <span class="m_l5 turnInlineBlock">积分</span>
                  </el-form-item>

                  <el-button
                    :size="size"
                    type="text"
                    @click="addOrderGivenStairArr(index)"
                    v-show="index==0"
                    class="textBtn"
                  >添加</el-button>
                  <el-button
                    :size="size"
                    type="text"
                    @click="deelteOrderGivenStairArr(index)"
                    v-show="index != 0"
                    class="textRed noMarginL textBtn"
                  >删除</el-button>
                </el-form-item>
              </div>
              <el-form-item label="每日上限：" class="labelTextSize14 labelTextColor666 mb120">
                <el-input
                  placeholder="请输入数字"
                  v-model="rulePowerForm.giveIntegralMaxNum"
                  @input="rulePowerForm.giveIntegralMaxNum=rulePowerForm.giveIntegralMaxNum.replace(/[^\d.]/g,'')"
                  maxlength="5"
                  class="w350"
                  clearable
                ></el-input>
              </el-form-item>
            </el-form-item>
          </el-row>
          <el-row v-show="evaluate">
            <el-form>
              <el-checkbox-group v-model="whetherPicList">
                <el-form-item >
                  <el-row class="mb30">
                    <span class="font16 color000">评价赠送</span>
                  </el-row>
                  <el-row class="mb30">
                    <el-checkbox label="带图"></el-checkbox>
                  </el-row>
                  <el-form-item class="mb30 w200">
                    <span style="color:red">*</span>
                    <span class="turnInlineBlock ">完成评价赠送：</span>
                    <el-input
                      placeholder="输入数字"
                      v-model="rulePowerForm.havePictureMaxNum"
                      maxlength="5"
                      clearable
                      @input="rulePowerForm.havePictureMaxNum=rulePowerForm.havePictureMaxNum.replace(/[^\d.]/g,'')"
                    ></el-input>
                    <span class="turnInlineBlock m_l10">积分</span>
                  </el-form-item>
                </el-form-item>
                <el-form-item >
                  <el-form-item class="mb30 w200">
                    <span class="turnInlineBlock w109 t_r ">每日上限：</span>
                    <el-input
                      placeholder="输入数字"
                      v-model="rulePowerForm.havePictureGiveGrowthNum"
                      maxlength="5"
                      clearable
                      @input="rulePowerForm.havePictureGiveGrowthNum=rulePowerForm.havePictureGiveGrowthNum.replace(/[^\d.]/g,'')"
                    ></el-input>
                    <span class="turnInlineBlock m_l10">积分</span>
                  </el-form-item>
                </el-form-item>

                <el-form-item >
                  <el-row class="mb30">
                    <el-checkbox label="不带图"></el-checkbox>
                  </el-row>
                  <el-form-item class="mb30 w200">
                    <span style="color:red">*</span>
                    <span class="turnInlineBlock ">完成评价赠送：</span>
                    <el-input
                      placeholder="输入数字"
                      v-model="rulePowerForm.giveGrowthNum"
                      maxlength="5"
                      clearable
                      @input="rulePowerForm.giveGrowthNum=rulePowerForm.giveGrowthNum.replace(/[^\d.]/g,'')"
                    ></el-input>
                    <span class="turnInlineBlock m_l10">积分</span>
                  </el-form-item>
                </el-form-item>
                <el-form-item >
                  <el-form-item class="w200 mb120">
                    <span class="turnInlineBlock w109 t_r">每日上限：</span>
                    <el-input
                      placeholder="输入数字"
                      v-model="rulePowerForm.giveGrowthMaxNum"
                      maxlength="5"
                      clearable
                      @input="rulePowerForm.giveGrowthMaxNum=rulePowerForm.giveGrowthMaxNum.replace(/[^\d.]/g,'')"
                    ></el-input>
                    <span class="turnInlineBlock m_l10">积分</span>
                  </el-form-item>
                </el-form-item>
              </el-checkbox-group>
            </el-form>
          </el-row>
          <el-row v-show="share">
            <el-form-item class="mb30">
              <span class="font16 color000">分享赠送</span>
            </el-form-item>
            <el-form-item class="mb30 w200 labelTextSize14 labelTextColor666 labelMarginRight10">
              <span style="color:red">*</span>
              <span>完成分享赠送：</span>
              <el-input
                placeholder="请输入"
                clearable
                v-model="rulePowerForm.giveIntegralNum"
                @input="rulePowerForm.giveIntegralNum=rulePowerForm.giveIntegralNum.replace(/[^\d.]/g,'')"
                maxlength="5"
              ></el-input>
              <span class="turnInlineBlock m_l10 mr10">积分</span>
            </el-form-item>
            <el-form-item  class="mb120 w200   " >
              <span class="turnInlineBlock w109 t_r color666 font14">每日上限：</span>
              <el-input
                placeholder="请输入"
                clearable
                v-model="rulePowerForm.giveIntegralMaxNum"
                @input="rulePowerForm.giveIntegralMaxNum=rulePowerForm.giveIntegralMaxNum.replace(/[^\d.]/g,'')"
                maxlength="5"
              ></el-input>
              <span class="turnInlineBlock m_l10">积分</span>
            </el-form-item>
          </el-row>
          <el-row v-show="sun">
            <el-form-item class="mb30">
              <span class="font16 color000">嗮单赠送</span>
            </el-form-item>
            <el-form-item class="mb30 w200 labelTextSize14 labelTextColor666 labelMarginRight10">
              <span style="color:red">*</span>
              <span class="font14 color666">完成晒单赠送：</span>
              <el-input
                placeholder="请输入"
                clearable
                v-model="rulePowerForm.giveIntegralNum"
                @input="rulePowerForm.giveIntegralNum=rulePowerForm.giveIntegralNum.replace(/[^\d.]/g,'')"
                maxlength="5"
              ></el-input>
              <span class="turnInlineBlock m_l10 mr10">积分</span>
            </el-form-item>
            <el-form-item  class="mb120 w200 ">
              <span class="turnInlineBlock w108 color666 font14 t_r">每日上限：</span>
              <el-input
                placeholder="请输入"
                clearable
                v-model="rulePowerForm.giveIntegralMaxNum"
                @input="rulePowerForm.giveIntegralMaxNum=rulePowerForm.giveIntegralMaxNum.replace(/[^\d.]/g,'')"
                maxlength="5"
              ></el-input>
              <span class="turnInlineBlock m_l10">积分</span>
            </el-form-item>
          </el-row>
          <el-row v-show="collection">
            <el-form-item>
              <span class="font16 color000">收藏赠送</span>
            </el-form-item>
            <el-form-item class="mb30 w200 labelTextSize14 labelTextColor666 labelMarginRight10">
              <span style="color:red">*</span>
              <span class="font14 color666">完成收藏赠送：</span>
              <el-input
                placeholder="请输入"
                clearable
                v-model="rulePowerForm.giveIntegralNum"
                @input="rulePowerForm.giveIntegralNum=rulePowerForm.giveIntegralNum.replace(/[^\d.]/g,'')"
                maxlength="5"
              ></el-input>
              <span class="turnInlineBlock m_l10 mr10">积分</span>
            </el-form-item>
            <el-form-item  class="mb120 w200 ">
              <span class="turnInlineBlock w109 t_r color666 font14">每日上限：</span>
              <el-input
                placeholder="请输入"
                clearable
                v-model="rulePowerForm.giveIntegralMaxNum"
                @input="rulePowerForm.giveIntegralMaxNum=rulePowerForm.giveIntegralMaxNum.replace(/[^\d.]/g,'')"
                maxlength="5"
              ></el-input>
              <span class="turnInlineBlock m_l10">积分</span>
            </el-form-item>
          </el-row>
          <el-row v-show="praise">
            <el-form-item class="mb30">
              <span class="font16 color000">点赞赠送</span>
            </el-form-item>
            <el-form-item class="mb30 w200 labelTextSize14 labelTextColor666 labelMarginRight10">
              <span style="color:red">*</span>
              <span class="font14 color666">完成点赞赠送：</span>
              <el-input
                placeholder="请输入"
                clearable
                v-model="rulePowerForm.giveIntegralNum"
                @input="rulePowerForm.giveIntegralNum=rulePowerForm.giveIntegralNum.replace(/[^\d.]/g,'')"
                maxlength="5"
              ></el-input>
              <span class="turnInlineBlock m_l10 mr10">积分</span>
            </el-form-item>
            <el-form-item  class="mb120 w200 ">
              <span class="color666 font14 turnInlineBlock w109 t_r">每日上限：</span>
              <el-input
                placeholder="请输入"
                clearable
                v-model="rulePowerForm.giveIntegralMaxNum"
                @input="rulePowerForm.giveIntegralMaxNum=rulePowerForm.giveIntegralMaxNum.replace(/[^\d.]/g,'')"
                maxlength="5"
              ></el-input>
              <span class="turnInlineBlock m_l10">积分</span>
            </el-form-item>
          </el-row>
        </el-form>
        <div class="t_c">
          <el-button
            :size="size"
            type="primary"
            @click="upStep(2)"
            :loading="editLoading"
            class="mr60"
          >上一步</el-button>
          <el-button
            :size="size"
            type="primary"
            @click="nextStepRulePower(2)"
            :loading="editLoading"
          >下一步</el-button>
          <el-button
            :size="size"
            type="primary"
            @click="returnRuleList"
          >返回规则列表</el-button>
        </div>
      </el-tab-pane>

      <el-tab-pane :label="addRuleSuccess" :disabled="true" name="third">
        <div class="positionDes">
            <span class="ruleClass font16">
             <img src="../../../assets/success.png" class="successImg" />
              <span>规则创建成功</span>
            </span>
          <img v-bind:src="imgUrl" />
        </div>
        <div class="positionDes">
            <span
              class="ruleDes font12 colorOrange mb120 turnInlineBlock"
              v-show="addSuccess == true"
            >该规则现为【停用】状态，请手动操作【启用】</span>
        </div>
        <div class="positionDes">
          <el-button :size="size" type="primary" @click="returnRuleList">返回</el-button>
        </div>
      </el-tab-pane>
    </el-tabs>

  </el-container>
</template>
<script>
import KtButton from "@/views/Core/KtButton";
export default {
  components: {
    KtButton
  },
  data() {
    return {
      size: "mini",
      rulePowerForm: {
        consumeIntegralNum: null,
        ruleType: 1,
        orderConsume: null,
        deptName: null,
        mememberIntegraIncrement: [{ consumeNum: "", giveIntegralNum: "" }],
        consumeFlag: null,
        orderFlag: null,
        flag: null,
        share: null,
        consumeNum: null,
        phasedConsumeNum: null,
        ruleName: null,
        ruleNum: null,
        giveIntegralNum: null,
        giveIntegralMaxNum: null,
        consumeMode: null,
        obtainMode: null,
        giveGrowthMaxNum: null,
        notPictureGiveGrowthNum: null,
        havePictureMaxNum: null,
        havePictureGiveGrowthNum: null,
        giveGrowthNum: null,
        obtainModeName: null,
        exchangeType: 1,
      },
      editTypeDis: false, //规则获取方式默认可选取
      obtainModeTypeList: [
        {
          "obtainMode": 1,
          "obtainName": "下单赠送"
        },{
          "obtainMode": 2,
          "obtainName": "注册赠送"
        },{
          "obtainMode": 3,
          "obtainName": "评价赠送"
        },
        {
          "obtainMode": 5,
          "obtainName": "分享赠送"
        },{
          "obtainMode": 6,
          "obtainName": "点赞赠送"
        },

        {
          "obtainMode": 8,
          "obtainName": "收藏赠送"
        },
      ],
      give:false,
      order:false,
      recharge:false,
      evaluate:false,
      share:false,
      collection:false,
      praise:false,
      sun:false,
      imgUrl: "",
      addRuleSuccess: "创建成功",
      addSuccess: true,
      editLoading: false,
      whetherPicList: [],
      activeName: "first",
    };
  },
  methods: {
    //下拉选
    selectModel(id) {
      let obj = {};
      let selectModel = {};
      obj = this.obtainModeTypeList.find(item => {
        if (item.obtainMode == id) {
          this.rulePowerForm.obtainMode = id;
          this.rulePowerForm.obtainName = item.obtainName;
          this.rulePowerForm.obtainModeName = item.obtainName;

          if (item.obtainMode == 1) {
            //下单赠送
            this.share = false;
            this.sun = false;
            this.collection = false;
            this.praise = false;
            this.evaluate = false;
            this.give = false;
            this.order = true;
            this.recharge = false;
          } else if (item.obtainMode == 2) {
            //注册赠送
            this.share = false;
            this.sun = false;
            this.order = false;
            this.collection = false;
            this.praise = false;
            this.evaluate = false;
            this.give = true;
            this.recharge = false;
          } else if (item.obtainMode == 3) {
            //评价
            this.share = false;
            this.sun = false;
            this.give = false;
            this.order = false;
            this.collection = false;
            this.praise = false;
            this.evaluate = true;
            this.recharge = false;
          } else if (item.obtainMode == 4) {
            //充值
            this.share = false;
            this.sun = false;
            this.evaluate = false;
            this.give = false;
            this.order = false;
            this.collection = false;
            this.praise = false;
            this.recharge = true;
          } else if (item.obtainMode == 5) {
            //分享
            this.sun = false;
            this.evaluate = false;
            this.give = false;
            this.order = false;
            this.collection = false;
            this.praise = false;
            this.share = true;
            this.recharge = false;
          } else if (item.obtainMode == 6) {
            //点赞
            this.share = false;
            this.sun = false;
            this.evaluate = false;
            this.give = false;
            this.order = false;
            this.collection = false;
            this.collection = false;
            this.praise = true;
            this.recharge = false;
          } else if (item.obtainMode == 7) {
            this.praise = false;
            this.share = false;
            this.evaluate = false;
            this.give = false;
            this.order = false;
            //嗮单
            this.collection = false;
            this.sun = true;
            this.recharge = false;
          } else if (item.obtainMode == 8) {
            this.sun = false;
            this.praise = false;
            this.share = false;
            this.evaluate = false;
            this.give = false;
            this.order = false;
            this.recharge = false;
            //收藏
            this.collection = true;
          }
        }
      });
    },
    //规则获取下一步
    nextStepRulePower(data) {
      var this_ = this;
      if (data == 1) {
        if (
          "" == this.rulePowerForm.ruleName ||
          null == this.rulePowerForm.ruleName
        ) {
          this_.$message({ message: "请输入规则名称", type: "error" });
          return;
        }
        if (
          "" == this.rulePowerForm.obtainMode ||
          null == this.rulePowerForm.obtainMode
        ) {
          this_.$message({ message: "请选择获取类型", type: "error" });
          return;
        }
        this_.activeName = "second";
      } else if (data == 2) {
        this_.rulePowerForm.ruleType = 1;
        if (
          this_.rulePowerForm.obtainMode != 1 &&
          this_.rulePowerForm.obtainMode != 4 &&
          this_.rulePowerForm.obtainMode != 3
        ) {
          if (
            "" == this_.rulePowerForm.giveIntegralNum ||
            null == this_.rulePowerForm.giveIntegralNum
          ) {
            this_.$message({ message: "请输入积分规则", type: "error" });
            return;
          } else if (
            "" != this_.rulePowerForm.giveIntegralMaxNum &&
            null != this_.rulePowerForm.giveIntegralMaxNum
          ) {
            //判断每日成长上限是否为空
            if (
              Number(this_.rulePowerForm.giveIntegralNum) >
              Number(this_.rulePowerForm.giveIntegralMaxNum)
            ) {
              this_.$message({
                message: "每日上限需大于或等于单次赠送值",
                type: "error"
              });
              return;
            } else {
              let params = Object.assign({}, this_.rulePowerForm);
            }
          } else {
            let params = Object.assign({}, this_.rulePowerForm);
          }
        } else if (this_.rulePowerForm.obtainMode == 1) {
          //如果是下单赠送
          /* 先判断是否是阶梯赠送 */
          if (this_.rulePowerForm.orderFlag != 2) {
            //如果不是阶梯赠送
            if (
              "" == this_.rulePowerForm.giveIntegralNum ||
              null == this_.rulePowerForm.giveIntegralNum
            ) {
              this_.$message({ message: "请输入积分规则", type: "error" });
              return;
            } else if (
              "" == this_.rulePowerForm.consumeNum ||
              null == this_.rulePowerForm.consumeNum
            ) {
              this_.$message({ message: "请输入消费金额", type: "error" });
              return;
            } else if (null != this_.rulePowerForm.giveIntegralMaxNum) {
              if (
                Number(this_.rulePowerForm.giveIntegralNum) >
                Number(this_.rulePowerForm.giveIntegralMaxNum)
              ) {
                this_.$message({
                  message: "每日上限需大于或等于单次赠送值",
                  type: "error"
                });
                return;
              } else {
                let params = Object.assign({}, this_.rulePowerForm);
                params.orderFlag = 1;
              }
            } else {
              let params = Object.assign({}, this_.rulePowerForm);
              params.orderFlag = 1;
            }
          } else {
            if (
              null == this_.rulePowerForm.giveIntegralMaxNum ||
              "" == this_.rulePowerForm.giveIntegralMaxNum
            ) {
              let temp = this_.rulePowerForm.mememberIntegraIncrement;
              let flag = false;
              for (let i = 0; i < temp.length; i++) {
                if (
                  "" == temp[i].giveIntegralNum ||
                  null == temp[i].giveIntegralNum ||
                  "" == temp[i].consumeNum ||
                  null == temp[i].consumeNum
                ) {
                  this_.$message({
                    message: "下单赠送积分规则不能为空!请输入",
                    type: "error"
                  });
                  flag = false;
                  break;
                } else {
                  flag = true;
                }
              }
              if(!flag){
                return;
              }
            } else {
              let temp = this_.rulePowerForm.mememberIntegraIncrement;
              let flag = false;
              for (let i = 0; i < temp.length; i++) {
                if (
                  "" == temp[i].giveIntegralNum ||
                  null == temp[i].giveIntegralNum ||
                  "" == temp[i].consumeNum ||
                  null == temp[i].consumeNum
                ) {
                  this_.$message({
                    message: "下单赠送积分规则不能为空!请输入",
                    type: "error"
                  });
                  flag = false;
                  return;
                } else {
                  flag = true;
                }
              }
              if(!flag){
                return;
              }
              let sum = Number(0);
              for (let j = 0; j < temp.length; j++) {
                sum += Number(temp[j].giveIntegralNum);
              }
              if (sum > this_.rulePowerForm.giveIntegralMaxNum) {
                this_.$message({
                  message: "每日上限需大于或等于单次赠送值",
                  type: "error"
                });
                return;
              }
            }
            let params = Object.assign({}, this_.rulePowerForm);
            params.orderFlag = 2;
          }
        } else if (this_.rulePowerForm.obtainMode == 4) {
          //如果是充值赠送
          /* 先判断是否是阶梯赠送 */
          if (this_.rulePowerForm.consumeFlag != 2) {
            //如果不是阶梯赠送
            if (
              "" == this_.rulePowerForm.giveIntegralNum ||
              null == this_.rulePowerForm.giveIntegralNum
            ) {
              this_.$message({ message: "请输入积分规则", type: "error" });
              return;
            } else if (
              "" == this_.rulePowerForm.consumeNum ||
              null == this_.rulePowerForm.consumeNum
            ) {
              this_.$message({ message: "请输入充值金额", type: "error" });
              return;
            } else if (null != this_.rulePowerForm.giveIntegralMaxNum) {
              if (
                Number(this_.rulePowerForm.giveIntegralNum) >
                Number(this_.rulePowerForm.giveIntegralMaxNum)
              ) {
                this_.$message({
                  message: "每日上限需大于或等于单次赠送值",
                  type: "error"
                });
                return;
              } else {
                let params = Object.assign({}, this_.rulePowerForm);
                params.consumeFlag = 1;
              }
            } else {
              let params = Object.assign({}, this_.rulePowerForm);
              params.consumeFlag = 1;
            }
          } else {
            if (
              null == this_.rulePowerForm.giveIntegralMaxNum ||
              "" == this_.rulePowerForm.giveIntegralMaxNum
            ) {
              let temp = this_.rulePowerForm.mememberIntegraIncrement;
              let flag = false;
              for (let i = 0; i < temp.length; i++) {
                if (
                  "" == temp[i].giveIntegralNum ||
                  null == temp[i].giveIntegralNum ||
                  "" == temp[i].consumeNum ||
                  null == temp[i].consumeNum
                ) {
                  this_.$message({
                    message: "充值赠送积分规则不能为空!请输入",
                    type: "error"
                  });
                  flag = false;
                  break;
                } else {
                  flag = true;
                }
              }
              if(!flag){
                return;
              }
            } else {
              let temp = this_.rulePowerForm.mememberIntegraIncrement;
              let flag = false;
              for (let i = 0; i < temp.length; i++) {
                if (
                  "" == temp[i].giveIntegralNum ||
                  null == temp[i].giveIntegralNum ||
                  "" == temp[i].consumeNum ||
                  null == temp[i].consumeNum
                ) {
                  this_.$message({
                    message: "充值赠送积分规则不能为空!请输入",
                    type: "error"
                  });
                  flag = false;
                  return;
                } else {
                  flag = true;
                }
              }
              if(!flag){
                return;
              }
              let sum = Number(0);
              for (let j = 0; j < temp.length; j++) {
                sum += Number(temp[j].giveIntegralNum);
              }
              if (sum > this_.rulePowerForm.giveIntegralMaxNum) {
                this_.$message({
                  message: "每日上限需大于或等于单次赠送值",
                  type: "error"
                });
                return;
              }
            }
            let params = Object.assign({}, this_.growthRuleForm);
            params.consumeFlag = 2;
          }
        } else if (this_.rulePowerForm.obtainMode == 3) {
          //如果是评价赠送
          /* 先判断评价类型 */
          if(this_.whetherPicList.length==0){
            this_.$message({
              message: "至少勾选一项",
              type: "error"
            });return;
          }
          if (
            this_.whetherPicList.length == 1 &&
            this_.whetherPicList[0] == "带图"
          ) {
            if (
              "" == this_.rulePowerForm.havePictureMaxNum ||
              null == this_.rulePowerForm.havePictureMaxNum
            ) {
              this_.$message({
                message: "请输入带图评价赠送规则",
                type: "error"
              });
              return;
            } else if (null != this_.rulePowerForm.havePictureGiveGrowthNum) {
              if(null !=this_.rulePowerForm.havePictureGiveGrowthNum && "" !=this_.rulePowerForm.havePictureGiveGrowthNum){
                if (Number(this_.rulePowerForm.havePictureMaxNum) > Number(this_.rulePowerForm.havePictureGiveGrowthNum)) {
                  this_.$message({
                    message: "每日上限需大于或等于单次赠送值",
                    type: "error"
                  });
                  return;
                } else {
                  let params = Object.assign({}, this_.rulePowerForm);
                  params.flag = 1;
                }
              }
            }
            let params = Object.assign({}, this_.rulePowerForm);
            params.flag = 1;
          } else if (
            this_.whetherPicList.length == 1 &&
            this_.whetherPicList[0] == "不带图"
          ) {
            if (
              "" == this_.rulePowerForm.giveGrowthNum ||
              null == this_.rulePowerForm.giveGrowthNum
            ) {
              this_.$message({
                message: "请输入不带图评价赠送规则",
                type: "error"
              });
              return;
            } else if (null != this_.rulePowerForm.giveGrowthMaxNum) {
              if(null !=this_.rulePowerForm.giveGrowthMaxNum){
                if (
                  Number(this_.rulePowerForm.giveGrowthNum) >
                  Number(this_.rulePowerForm.giveGrowthMaxNum)
                ) {
                  this_.$message({
                    message: "每日上限需大于或等于单次赠送值",
                    type: "error"
                  });
                  return;
                } else {
                  let params = Object.assign({}, this_.rulePowerForm);
                  params.flag = 2;
                }
              }
            }
            let params = Object.assign({}, this_.rulePowerForm);
            params.flag = 2;
          } else {
            if (null == this_.rulePowerForm.havePictureMaxNum || null == this_.rulePowerForm.giveGrowthNum) {
              this_.$message({ message: "请输入评价赠送规则", type: "error" });
              return;
            } else if (
              null != this_.rulePowerForm.havePictureGiveGrowthNum &&
              "" != this_.rulePowerForm.havePictureGiveGrowthNum &&
              null != this_.rulePowerForm.giveGrowthMaxNum &&
              "" != this_.rulePowerForm.giveGrowthMaxNum
            ) {
              if (
                Number(this_.rulePowerForm.havePictureMaxNum) >
                Number(this_.rulePowerForm.havePictureGiveGrowthNum)  ||
                Number(this_.rulePowerForm.giveGrowthNum) >
                Number(this_.rulePowerForm.giveGrowthMaxNum)
              ) {
                this_.$message({
                  message: "每日上限需大于或等于单次赠送值",
                  type: "error"
                });
                return;
              } else {
                let params = Object.assign({}, this_.rulePowerForm);
                params.flag = 3;
              }
            } else if (null != this_.rulePowerForm.giveGrowthMaxNum && "" != this_.rulePowerForm.giveGrowthMaxNum) {
              if (
                Number(this_.rulePowerForm.giveGrowthNum) >
                Number(this_.rulePowerForm.giveGrowthMaxNum)
              ) {
                this_.$message({
                  message: "每日上限需大于或等于单次赠送值",
                  type: "error"
                });
                return;
              } else {
                let params = Object.assign({}, this_.rulePowerForm);
                params.flag = 3;
              }
            } else {
              if(null !=this_.rulePowerForm.havePictureGiveGrowthNum){
                if (Number(this_.rulePowerForm.havePictureMaxNum) > Number(this_.rulePowerForm.havePictureGiveGrowthNum)) {
                  this_.$message({
                    message: "每日上限需大于或等于单次赠送值",
                    type: "error"
                  });
                  return;
                } else {
                  let params = Object.assign({}, this_.rulePowerForm);
                  params.flag = 3;
                }
              }
            }
            let params = Object.assign({}, this_.rulePowerForm);
            params.flag = 3;
          }
        } else if (this_.rulePowerForm.obtainMode > 8) {
          if (
            "" == this_.rulePowerForm.giveIntegralNum ||
            null == this_.rulePowerForm.giveIntegralNum
          ) {
            this_.$message({ message: "请输入积分规则", type: "error" });
            return;
          } else if (
            "" != this_.rulePowerForm.giveIntegralMaxNum &&
            null != this_.rulePowerForm.giveIntegralMaxNum
          ) {
            //判断每日成长上限是否为空
            if (
              Number(this_.rulePowerForm.giveIntegralNum) >
              Number(this_.rulePowerForm.giveIntegralMaxNum)
            ) {
              this_.$message({
                message: "每日上限需大于或等于单次赠送值",
                type: "error"
              });
              return;
            } else {
              let params = Object.assign({}, this_.rulePowerForm);
            }
          } else {
            let params = Object.assign({}, this_.rulePowerForm);
          }
        }
        /* 判断是否带图 */
        if (
          this_.whetherPicList.length == 1 &&
          this_.whetherPicList[0] == "带图"
        ) {
          this_.rulePowerForm.flag = 1;
        } else if (
          this_.whetherPicList.length == 1 &&
          this_.whetherPicList[0] == "不带图"
        ) {
          this_.rulePowerForm.flag = 2;
        } else {
          this_.rulePowerForm.flag = 3;
        }
        let params = Object.assign({}, this_.rulePowerForm);

        params = Object.assign({}, this_.rulePowerForm);
        params.storeMember=2;
        params.giveGrowthMaxNum = params.giveGrowthMaxNum == ""? 0 : params.giveGrowthMaxNum;
        params.giveIntegralMaxNum = params.giveIntegralMaxNum == ""? 0 : params.giveIntegralMaxNum;
        params.havePictureMaxNum  = params.havePictureMaxNum == ""? 0 : params.havePictureMaxNum;
        params.obtainMode = this_.rulePowerForm.obtainMode;
        if (params.ruleId != null && params.ruleId != "") {

          this.obtainModeTypeList.find(item => {
            if (item.obtainName == params.obtainMode) {
              params.obtainMode = item.obtainMode
            }})
          this_.utils.request.editMemberIntegraInfo(params, function(res) {
            if (res.code == "0000") {
              this_.activeName = "third";
            } else {
              this_.$message({
                message: "操作失败, " + res.msg,
                type: "error"
              });
            }
          });
        } else {
          this_.utils.request.editIntegraRuleInfo(params, function(res) {
            if (res.code == "0000") {
              this_.activeName = "third";
            } else {
              this_.$message({
                message: "操作失败, " + res.msg,
                type: "error"
              });
            }
          });
        }
      }
    },
    // 新增订单规则
    addOrderGivenStairArr() {
      if (
        this.rulePowerForm.mememberIntegraIncrement.length != 0 &&
        this.rulePowerForm.mememberIntegraIncrement.length > 9
      ) {
        this.$message({ message: "新增最多不超过十条", type: "error" });
        return;
      } else {
        this.rulePowerForm.mememberIntegraIncrement.push({});
      }
    },
    deelteOrderGivenStairArr(index) {
      this.rulePowerForm.mememberIntegraIncrement.splice(index, 1);
    },

    //上一步
    upStep(data) {
      if (data == 2) {
        this.activeName = "first";
      } else if (data == 3) {
        this.activeName = "second";
      }
    },
    returnRuleList: function() {
      this.$router.push({path: '/pages/Member/IntegraRulelList'})
    },
  },
  mounted(){

  }
};
</script>

<style scoped lang='scss'>
  .type {
    display: flex;
    align-items: center;
  }
  .type p {
    text-align: right;
    margin-right: 20px;
    width: 120px;
  }
  .newUserOrder {
    margin-top: 2%;
    width: 20%;
    margin-left: 2%;
  }
  .font {
    font-size: 18px;
    font-weight: 800;
  }
  .ruleDes {
    color: #ffdead;
    font-size: 20px;
  }
  .positionDes {
    text-align: center;
    margin-top: 2%;
  }
  .ruleClass {
    font-size: 30px;
  }
  .everyCostHandleSel {
    /deep/ .el-input {
      width: 20%;
    }
  }
  .longInput {
    .timePicker {
      /deep/ .el-input {
        width: 201px !important;
      }
    }
  }
  .alignment {
    display: inline-block;
    height: 32px;
    line-height: 32px;
    font-size: 16px;
  }

  .input100 {
    /deep/ .el-input {
      width: 82px !important;
    }
  }
  .mb18 {
    margin-bottom: 18px;
  }

  .mt18 {
    margin-top: 18px;
  }

  // dialog标题的样式问题
  .span-title {
    font-size: 28px;
    color: #333333;
  }
  //下拉选择框icon对齐
  .iconAlignment {
    /deep/ .el-input__icon {
      line-height: 32px !important;
    }
  }
  .mb120 {
    margin-bottom: 120px !important;
  }
  .mr60 {
    margin-right: 60px !important;
  }
  /deep/ .w138 {
    width: 138px !important;
    /deep/ .el-input__inner {
      width: 138px !important;
    }
  }
  /deep/ .w350 {
    width: 350px !important;
    .el-input__inner {
      width: 350px !important;
    }
  }
  /deep/ .w365 {
    width: 365px !important;
    .el-input__inner {
      width: 365px !important;
    }
  }
  .textRed {
    color: red !important;
  }
  .noMarginL {
    margin-left: 0 !important;
  }
  .w70 {
    display: inline-block;
    width: 70px !important;
  }
  .colorOrange {
    color: #e7aa4e !important;
  }
  .turnInlineBlock {
    display: inline-block !important;
  }
  .successImg {
    width: 18px;
    height: 18px;
    vertical-align: middle;
  }
  /deep/ .w115 {
    display: inline-block;
    width: 110px;
    text-align: right;
  }

  .mb40 {
    margin-bottom: 40px;
  }
  .labelText {
    color: #999999;
    font-size: 16px;
  }
  .w125 {
    display: inline-block;
    width: 125px;
    text-align: right;
  }
  .w90 {
    display: inline-block;
    width: 90px;
    text-align: right;
  }
  /deep/ .editDialogInput125 {
    width: 120px !important;
    /deep/ .el-input__inner {
      width: 120px !important;
    }
  }
  /deep/ .editDialogInput78 {
    width: 71px !important;
    /deep/ .el-input__inner {
      width: 71px !important;
    }
  }
  /deep/ .w275 {
    width: 275px !important;
    /deep/ .el-input__inner {
      width: 275px !important;
    }
  }
  .color000 {
    color: #000000;
  }
  .color333 {
    color: #333333;
  }
  .color666 {
    color: #666666;
  }
  .textColAlignment {
    display: inline-block;
    height: 32px;
    line-height: 32px;
  }
  .labelNoHeight {
    /deep/ .el-form-item__label {
      height: 0 !important;
    }
  }
  .p_d40 {
    padding-left: 21px;
  }
  .w200 {
    /deep/ .el-input {
      width: 200px !important;
      /deep/ .el-input__inner {
        width: 200px !important;
      }
    }
  }
  .errorInfoPosition {
    /deep/ .el-form-item__error {
      left: 112px;
    }
  }
  .labelTextColor666 {
    /deep/ .el-form-item__label {
      color: #666666;
    }
  }
  .formItemNoMargin {
    margin-bottom: 0 !important;
  }
  .form-item-content-noMargin {
    /deep/ .el-form-item__content {
      margin-right: 0 !important;
    }
  }
  .width280 {
    width: 280px !important;
  }
  .m_l5 {
    margin-left: 5px !important;
  }
  .m_l10 {
    margin-left: 10px !important;
  }
  /deep/ .textBtn {
    padding: 0 5px !important;
  }
  .mr5 {
    margin-right: 5px;
  }
  .w108 {
    width: 108px;
  }
  .w120 {
    width: 120px;
  }
  .labelMarginRight10 {
    /deep/ .el-form-item__label {
      margin-right: 10px !important;
    }
  }
  /deep/ .w356 {
    width: 356px !important;
    /deep/ .el-input__inner {
      width: 356px !important;
    }
  }

  .w150 {
    /deep/ .el-input {
      width: 150px !important;
      /deep/ .el-input__inner {
        width: 150px;
      }
    }
  }
  /deep/ .inputInner_paddingRight16 {
    /deep/ .el-input__inner {
      padding-right: 16px !important;
    }
  }
  .width267 {
    width: 267px !important;
  }
  .el-dialog-style {
    /deep/ .el-dialog {
      width: 610px;
      padding-left: 40px;
      padding-right: 40px;
      padding-bottom: 40px;
      .el-dialog__body {
        padding: 0;
        padding-top: 40px;
        /deep/ .el-form-item__label {
          margin-right: 0 !important;
        }
      }
    }
  }
  .search-input {
    .times {
      .times-to {
        padding: 0 10px;
        height: 32px;
        line-height: 32px;
        color: #999;
        display: inline-block;
      }
      /deep/ .el-input {
        width: 208px !important;
        .el-input__inner {
          width: 208px !important;
        }
      }
    }
  }
  .specicalTable{
    /deep/ .el-button{
      margin-left: 0 !important;
    }
  }
  .w109{
    width: 109px;
  }
  .w280{
    /deep/ .el-input{
      width: 280px !important;
      .el-input__inner{
        width: 280px;
      }
    }
  }
  .w129{
    width: 129px;
  }
</style>
